<?php
/**
 * Created by PhpStorm.
 * User: dy
 * Date: 2019/12/31
 * Time: 15:35
 */
namespace app\admin\validate;
use app\common\validate\BaseValidate;
use util\StringUtil;

class AuthGroupValidate extends BaseValidate
{
    protected $rule = [
        'module|模块'=>'require',
        'name|权限组名称'=>'require',
        'rules'=>'check_rule:'
    ];

    protected function check_rule($value,$rule,$data){
        if(!empty($value)){
            $rules_arr = StringUtil::instance()->strToArr($value);
            foreach ($rules_arr as $rule_item){
                if(!is_numeric($rule_item)){
                    return '权限节点规格错误';
                }
            }
        }
        return true;
    }
}